<template>
	<view>
		<bg-video></bg-video>
		<cu-custom bgColor="bg-purple" :isBack="true">
			<block class="text-white " slot="content">门店教练主页</block>
		</cu-custom>
		<view>
			<rllr></rllr>
			<view>
				<view class="bg-white margin-top-sm">
					<view class="padding solid-bottom flex justify-between align-baseline">
						<view class="text-purple title">
							<text class="text-xxl  ">
								<text class="iconfont icon-fangjian"></text>
							</text>
							<text>所属门店</text>
						</view>
						<text class="text-lg">
							<text v-if="sqs.length > 0">{{sqs[1].mdname}}申请中</text>
							<text @tap="jiebang" class="text-red text-df" v-if="mdjl.storeid">解绑</text>
							<text @tap="toMdbd" class="text-purple text-df" v-else>绑定</text>
							<text class="cuIcon-right text-gray "></text>
						</text>
					</view>
				
					<view v-if="ssmd" class="padding flex justify-between">
						<text>门店：{{ssmd.sname}}</text>
						<text>店长：{{ssdz.dname}}</text>
					</view>
				</view>
				
				<view v-if="mdjl.storeid" class="bg-white margin-top-sm">
					<view class="padding solid-bottom flex justify-between align-baseline">
						<view class="text-purple title">
							<text class="text-xxl  ">
								<text class="iconfont icon-kecheng"></text>
							</text>
							<text>课程【{{kcInfo.total}}】</text>
						</view>
						<text class="text-lg">
							<text @tap="toKaike" class="text-red text-df">新增</text>
							<text class="cuIcon-right text-gray "></text>
						</text>
					</view>
				
					<view v-if="kcInfo.data.length > 0" class="padding">
						<view class="bg-white shadow radius margin-bottom-xs" v-for="(kc,index) in kcInfo.data" :key="index">
							<kc-item :path="'/pages/cmdjl'" :kc="kc"></kc-item>
						</view>
						<view class="text-center">
							<text @tap="toKcList" class="text-purple text-df">查看更多</text>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data: function() {
			return {
				ssdz: undefined,
				ssmd: undefined,
				kclxs: this.constant.lxmap,
				mdjl: this.store.state.mdjl,
				kcInfo: {
					current: 1,
					size: 16,
					total: 0,
					data: []
				},
				sqs: []
				
			};
		},
		onLoad: function(){
			this.loadMdjl();
			this.loadKcs();
		},
		methods: {
			toMdbd: function() {
				uni.navigateTo({
					url: "/pages/cmdjl/mdbd"
				});
			},
			jiebang: function() {
				this.api("/mdjl/delete").send({
					mdjlid: this.store.state.mdjl.mdjlid,
				}).then(data => {
					this.message.info("解绑成功");
					this.loadMdjl();
				});
			},
			loadMdjl: function() {
				this.api("/mdjl/get").send({
					mdjlid: this.store.state.mdjl.mdjlid,
				}).then(data => {
					this.ssdz = data.adz;
					this.ssmd = data.astore;
					if (data.sqs) {
						this.sqs = data.sqs;
					}
					
				});
			},
			loadKcs: function() {
				this.api("/kc/page").send({
					current: 1,
					size: 4,
					mdjlid: this.store.state.mdjl.mdjlid,
				}).then(data => {
					this.kcInfo.data = data.akechengs.records;
					this.kcInfo.total = data.akechengs.total;
				});
			},
			toKcList: function() {
				uni.navigateTo({
					url: "/pages/cmdjl/kc/list"
				});
			},
			toKaike: function() {
				uni.navigateTo({
					url: "/pages/cmdjl/kc/kaike"
				});
			},
		}
	}
</script>

<style>
</style>